๐ง Jenkins Email Notification and Build Triggers Guide
A simple, complete reference for configuring Jenkins triggers and email notifications โ explained in easy words! ๐
๐งฉ Parameterized Jenkins Jobsโ
โ What is a Parameterized Job?โ
A parameterized job allows users to input values when triggering a build. These inputs (parameters) are passed into the job to customize the behavior.
๐งฐ Common Parameter Typesโ
| Type | Description |
|---|---|
| ๐ String | Text input (e.g., version number) |
| ๐ Boolean | Checkbox (true / false) |
| ๐ Choice | Dropdown menu |
| ๐ Password | Secure hidden input |
| ๐ Multi-line String | Multi-line text |
| ๐ File | Upload a file |
| โก Active Choice ๐ | Dynamic options (via plugin) |
| ๐ฟ Git Parameter ๐ | Pick Git branches/tags (via plugin) |
โ๏ธ Example for Pipeline Jobsโ
pipeline {
agent any
parameters {
string(name: 'VERSION', defaultValue: '1.0', description: 'Version to deploy')
booleanParam(name: 'RUN_TESTS', defaultValue: true, description: 'Run tests?')
choice(name: 'ENV', choices: ['dev', 'stage', 'prod'], description: 'Target environment')
}
stages {
stage('Deploy') {
steps {
echo "Deploying version ${params.VERSION} to ${params.ENV}"
}
}
}
}
โฐ Jenkins Build Triggers โ Explained Simplyโ
| Trigger | Meaning | Example Use Case |
|---|---|---|
| ๐ Trigger builds remotely | Run build via URL or script | Use curl to trigger Jenkins |
| ๐ Build after other projects are built | Trigger this job after another finishes | Chain builds |
| โฒ๏ธ Build periodically | Run on schedule (CRON) | Every day at 9 AM |
| ๐ช GitHub hook trigger | GitHub sends signal to build | Webhook setup |
| ๐ Poll SCM | Jenkins checks Git for changes | Every 5 mins check for code changes |
๐ Example CRON: Build every 5 minutesโ
H/5 * * * *
๐ Jenkins Post-Build Triggers (Detailed)โ
| Option | Description | Use Case |
|---|---|---|
| โ Trigger only if build is stable | Run next job only if build is successful | Production deployment |
| โ ๏ธ Trigger even if build is unstable | Continue even if tests fail | Notify, generate reports |
| โ Trigger even if the build fails | Run next job on failure | Send alerts, collect logs |
| ๐ Always trigger (even if aborted) | Run regardless of result | Cleanup, release locks |
๐ซ "Ignore post-commit hooks" in Jenkinsโ
โ What is a post-commit hook?โ
A Git or GitHub feature that sends a signal to Jenkins after code is pushed.
โ What does "Ignore post-commit hooks" mean?โ
It means Jenkins will ignore webhook signals and wonโt build the job automatically.
๐ก When to useโ
- You only want Jenkins to poll Git (using Poll SCM)
- You donโt want automatic builds from webhooks
๐ง Jenkins Email Notification Setupโ
โ What it doesโ
Sends emails when a build fails, becomes unstable, or returns to normal.
๐ ๏ธ Step 1: Configure Global Settingsโ
Navigate to:
Manage Jenkins โ Configure System โ E-mail Notification
Set the following:
- ๐ฎ SMTP server:
smtp.gmail.com - ๐ SMTP port:
587 - ๐ Use SMTP Auth: โ
- ๐ค Username:
[email protected] - ๐ Password: App Password (not your Gmail password)
- ๐จ From Address:
[email protected]or your Gmail - ๐ TLS / SSL: Enable as required
โ Click Test Configuration
Also set the System Admin e-mail address at the top.
๐ฌ Step 2: Add Email Notification to Jobโ
- Open your Jenkins job
- Click Configure
- Scroll to Post-build Actions
- Click Add post-build action โ E-mail Notification
- Add recipients:
Optional checkboxes:
- โ๏ธ Send email for every unstable build
- โ๏ธ Send separate e-mails to individuals who broke the build
Click Save
โ Will Jenkins send email to [email protected]?โ
โ Yes, if:
- SMTP is properly configured
- The email address is valid
- The build fails or becomes unstable
๐ค From which email will Jenkins send?โ
From the email set in:
Manage Jenkins โ Configure System โ E-mail Notification โ From address
Usually:
๐งพ Summary: Jenkins Notifications & Triggersโ
| Feature | Purpose |
|---|---|
| ๐๏ธ Parameterized Jobs | Let users customize job input |
| ๐ Triggers | Auto-start job on events (push, schedule, scripts) |
| ๐ Post-build Triggers | Control what happens after job finishes |
| ๐ง Email Notification | Send emails on failure / unstable / stable |
| ๐ซ Ignore post-commit hooks | Prevent auto-builds from GitHub/Git |
๐ง Pro Tipโ
Always test email configuration using the "Test configuration by sending test e-mail" button in Jenkins settings! โ